<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>17.axios的并发请求</title>


</head>
<body>
<div id="app">

</div>


<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!--引入axios-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
   //1.创建查询所有请求
    function findAll() {
       return axios.get('http://localhost:8080/findAll?name=xiaochen');
    }
    //2.创建保存请求
    function save() {
        return axios.post('http://localhost:8080/save', {
            username: 'xiaochen',
            email: '5234@qq.com',
            age: 23,
            phone: '15352252514'
        });
    }
    //3.并发请求
    axios.all([findAll(), save()]).then(
        axios.spread(function (res1, res2) {
            console.log(res1.data);
            console.log(res2.data);
        })
    );

    const app = new Vue({
        el: '#app',
        data: {},
        methods: {},
        components: {}
    });
</script>
</body>
</html>